package com.xiaobo.bodada.controller;

import com.xiaobo.bodada.common.BaseResponse;
import com.xiaobo.bodada.common.ResultUtils;
import com.xiaobo.bodada.mapper.WebsiteAnalysisMapper;
import com.xiaobo.bodada.model.vo.WebVisitCountVO;
import com.xiaobo.bodada.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/website/statistic")
public class WebsiteStatisticController {
    @Resource
    private WebsiteAnalysisMapper websiteAnalysisMapper;
    @Resource
    private UserService userService;
    @GetMapping("/visit_count")
    public BaseResponse<List<WebVisitCountVO>> getVisitCount(HttpServletRequest request){
        // 是否登录
        userService.getLoginUser(request);
        List<WebVisitCountVO> visitCountVOS = websiteAnalysisMapper.doVisitCount();
        return ResultUtils.success(visitCountVOS);
    }
}
